package com.wanmait.baohan.service.Impl;


import com.github.pagehelper.PageInfo;
import com.wanmait.baohan.mapper.TravelApprovalMapper;
import com.wanmait.baohan.pojo.TravelApproval;
import com.wanmait.baohan.service.TravelApprovalService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

@Service
@Transactional
public class TravelApprovalServiceImpl implements TravelApprovalService {
   @Resource
   private TravelApprovalMapper travelApprovalMapper;


   @Override
   public PageInfo<TravelApproval> selectAllTravelApproval(Integer page, Integer limit,Integer node) {

      List<TravelApproval> lit = travelApprovalMapper.findOutTheFinalApprovalRresultOfEachApprovalForm(node);
      for (TravelApproval travelApproval : lit) {
         if (travelApproval.getState()!= null) {
            if(travelApproval.getState()==0)travelApproval.setStates("未通过");
            if (travelApproval.getState() == 1) travelApproval.setStates("待审批");
            if (travelApproval.getState() == 2) travelApproval.setStates("审批完成");
         }
      }

      PageInfo<TravelApproval> pageInfo = new PageInfo<>(lit,7);
      return pageInfo;
   }

   @Override
   public  TravelApproval selectTravelApprovalById(Integer id) {
      TravelApproval travelApproval = travelApprovalMapper.selectTravelApprovalById(id);
      return travelApproval;

   }

   @Override
   public void addApprovalInformation(TravelApproval travelApproval) {
      travelApprovalMapper.insertSelective(travelApproval);
   }

   @Override
   public List<TravelApproval> findApprovalToApplicationById(Integer id) {
      return travelApprovalMapper.findApprovalToApplicationById(id);
   }

   @Override
   public void modifyApprovalStatus(TravelApproval travelApproval) {
      travelApprovalMapper.modifyApprovalStatus(travelApproval);
   }

   @Override
   public void insert(TravelApproval object) {

   }

   @Override
   public void delete(Integer id) {

   }

   @Override
   public void delete(String ids) {

   }

   @Override
   public void update(TravelApproval object) {

   }

   @Override
   public TravelApproval findById(Integer id) {
      return null;
   }

   @Override
   public List<TravelApproval> findAll() {
      return null;
   }

   @Override
   public List<TravelApproval> findAll(TravelApproval object) {
      return null;
   }

   @Override
   public PageInfo<TravelApproval> findPage(int pageNum) {
      return null;
   }

   @Override
   public PageInfo<TravelApproval> findPage() {
      return null;
   }

   @Override
   public PageInfo<TravelApproval> findPage(int pageNum, TravelApproval object) {
      return null;
   }

   @Override
   public PageInfo<TravelApproval> findPage(TravelApproval object) {
      return null;
   }
}
